new Vue({
    el: "#app",
    data: {
        school: [
            {
                title: "打游戏",
                ischeck: true
            },
            {
                title: "看电视",
                ischeck: false
            },
        ],
        text: "",
        wcnum: 0,
        weinum: 0
    },
    methods: {
        add(e) {
            let obj = {
                title: this.text,
                ischeck: false
            }
            this.text == "" ? alert("不能为空") : this.school.push(obj);
            this.text = '';
        },
    },
    watch: {
        school: {
            handler: function (value) {
                this.weinum=0;
                this.wcnum=0;
                for (let i = 0; i < value.length; i++) {
                    if (value[i].ischeck == false) {
                        this.weinum++
                    }else{
                        this.wcnum++
                    }
                }
            },
            deep: true,
            immediate: true
        }
    },
})